package com.kobe.manager.bidManager.controller;

import com.kobe.common.annotation.Anonymous;
import com.kobe.common.core.controller.BaseController;
import com.kobe.common.core.domain.AjaxResult;
import com.kobe.common.core.page.TableDataInfo;
import com.kobe.manager.bidManager.domain.Bid;
import com.kobe.manager.bidManager.service.IBidService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/kobe/manager/bid")
@Anonymous
public class BidController extends BaseController {

    @Autowired
    private IBidService bidService;

    @RequestMapping("/list")
    public TableDataInfo list(Bid bid){
        System.out.println("前端传来数据:"+bid);
        //分页
        startPage();
        List<Bid> list= bidService.selectBidList(bid);


        System.out.println("后端返回数据:"+list);
        return getDataTable(list);

    }

    @RequestMapping("/add")
    public AjaxResult add(@RequestBody  Bid bid){
        System.out.println( bid);
    	return bidService.add(bid);
    }

    //修改
    @RequestMapping("/update")
    public AjaxResult update(@RequestBody Bid bid){

    	return bidService.update(bid);
    }

    @PostMapping("/delete")
    public AjaxResult delete(@RequestBody Long[] ids){
        if (ids == null || ids.length == 0) {
            return AjaxResult.error("请选择要删除的数据");
        }
        return bidService.delete(ids);
    }
}
